package com.co.vote.web.controller.admin;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.co.common.utils.PageReq;
import com.co.server.entity.advice.TAdvice;
import com.co.server.entity.advice.aide.TAdviceQuery;
import com.co.server.entity.link.TLink;
import com.co.server.entity.link.aide.TLinkQuery;
import com.co.server.entity.note.TNote;
import com.co.server.entity.note.aide.TNoteQuery;
import com.co.server.entity.user.TUsers;
import com.co.server.entity.user.aide.TUsersQuery;
import com.co.server.entity.vote.TClass;
import com.co.server.entity.vote.TComment;
import com.co.server.entity.vote.TLabel;
import com.co.server.entity.vote.TVote;
import com.co.server.entity.vote.aide.TClassQuery;
import com.co.server.entity.vote.aide.TCommentQuery;
import com.co.server.entity.vote.aide.TLabelQuery;
import com.co.server.entity.vote.aide.TVoteQuery;
import com.co.server.service.advice.TAdviceService;
import com.co.server.service.link.TLinkService;
import com.co.server.service.note.TNoteService;
import com.co.server.service.user.TUsersService;
import com.co.server.service.vote.TClassService;
import com.co.server.service.vote.TCommentService;
import com.co.server.service.vote.TLabelService;
import com.co.server.service.vote.TVoteService;

/**
 * 后台管理，是否要新起项目 ，优先级排后
 * @author ZYL
 * @date 2016年12月9日 下午5:59:05
 */
@Controller
@RequestMapping("/admin")
public class AdminController {
	//登录
	
	@Resource
	private TVoteService tVoteService;
	@Resource
	private TClassService tClassService;
	@Resource
	private TLabelService tLabelService;
	@Resource
	private TLinkService tLinkService;
	@Resource
	private TUsersService tUsersService;
	@Resource
	private TCommentService tCommentService;
	@Resource
	private TNoteService tNoteService;
	@Resource
	private TAdviceService tAdviceService;
//	@Resource
//	private TVoteItemService tVoteItemService;
//	@Resource
//	private TVoteLabelService tVoteLabelService;
	
	//投票表
	@RequestMapping(value = "/voteList", method = { RequestMethod.GET, RequestMethod.POST })
	public String voteList( Model model,HttpSession session,PageReq pageReq,TVoteQuery query ) {
		Page<TVote> page = tVoteService.queryPageList(query, pageReq);
		model.addAttribute("page", page);
		return "/admin/voteList";
	}
	//作废
	
	//分类表
	@RequestMapping(value = "/classList", method = { RequestMethod.GET, RequestMethod.POST })
	public String classList( Model model,HttpSession session,PageReq pageReq,TClassQuery query ) {
		Page<TClass> page = tClassService.queryPageList(query, pageReq);
		model.addAttribute("page", page);
		return "/admin/classList";
	}
	//新增  作废
	
	//标签表
	@RequestMapping(value = "/labelList", method = { RequestMethod.GET, RequestMethod.POST })
	public String labelList( Model model,HttpSession session,PageReq pageReq,TLabelQuery query ) {
		Page<TLabel> page = tLabelService.queryPageList(query, pageReq);
		model.addAttribute("page", page);
		return "/admin/labelList";
	}
	//作废
	
	//友情链接表
	@RequestMapping(value = "/linkList", method = { RequestMethod.GET, RequestMethod.POST })
	public String linkList( Model model,HttpSession session,PageReq pageReq,TLinkQuery query ) {
		Page<TLink> page = tLinkService.queryPageList(query, pageReq);
		model.addAttribute("page", page);
		return "/admin/linkList";
	}
	//新增 修改 作废 删除
	
	//用户表 
	@RequestMapping(value = "/usersList", method = { RequestMethod.GET, RequestMethod.POST })
	public String usersList( Model model,HttpSession session,PageReq pageReq,TUsersQuery query ) {
		Page<TUsers> page = tUsersService.queryPageList(query, pageReq);
		model.addAttribute("page", page);
		return "/admin/usersList";
	}
	//作废
	
	//评论表
	@RequestMapping(value = "/commentList", method = { RequestMethod.GET, RequestMethod.POST })
	public String commentList( Model model,HttpSession session,PageReq pageReq,TCommentQuery query ) {
		Page<TComment> page = tCommentService.queryPageList(query, pageReq);
		model.addAttribute("page", page);
		return "/admin/commentList";
	}
	//作废
	
	//note表
	@RequestMapping(value = "/noteList", method = { RequestMethod.GET, RequestMethod.POST })
	public String noteList( Model model,HttpSession session,PageReq pageReq,TNoteQuery query ) {
		Page<TNote> page = tNoteService.queryPageList(query, pageReq);
		model.addAttribute("page", page);
		return "/admin/noteList";
	}
	//作废
	
	//意见表
	@RequestMapping(value = "/adviceList", method = { RequestMethod.GET, RequestMethod.POST })
	public String adviceList( Model model,HttpSession session,PageReq pageReq,TAdviceQuery query ) {
		Page<TAdvice> page = tAdviceService.queryPageList(query, pageReq);
		model.addAttribute("page", page);
		return "/admin/adviceList";
	}
	//修改 作废
	
	
}
